cmake_minimum_required(VERSION 3.0.2)
project(aloam_velodyne)

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "-std=c++14")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")

find_package(catkin REQUIRED COMPONENTS
        geometry_msgs
        nav_msgs
        sensor_msgs
        roscpp
        rospy
        rosbag
        std_msgs
        image_transport
        cv_bridge
        tf
        )

#find_package(Eigen3 REQUIRED)
find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Ceres REQUIRED)
find_package(GTSAM REQUIRED)
find_package(Boost COMPONENTS REQUIRED)

catkin_package(
        CATKIN_DEPENDS geometry_msgs nav_msgs roscpp rospy std_msgs
        DEPENDS EIGEN3 PCL Boost
        INCLUDE_DIRS include
        LIBRARIES aloam
)

include_directories(
        include
        ${PROJECT_SOURCE_DIR}
        ${PROJECT_SOURCE_DIR}/include
        ${catkin_INCLUDE_DIRS}
        ${PCL_INCLUDE_DIRS}
        ${CERES_INCLUDE_DIRS}
        ${OpenCV_INCLUDE_DIRS}
        ${Boost_INCLUDE_DIRS}
        ${TBB_INCLUDE_DIRS}
        ${PROJECT_SOURCE_DIR}/../../devel/include/gtsam
        ${PROJECT_SOURCE_DIR}/../../devel/include/eigen3
)

add_definitions(${PCL_DEFINITIONS})

add_library(${PROJECT_NAME} SHARED
        src/aloam/points_segmentation/projection_params.cpp
        src/aloam/points_segmentation/scan_projection.cpp
        src/aloam/points_segmentation/rich_point.cpp
        src/aloam/points_segmentation/feature_extractor/depth_ground_remover.cpp
        src/aloam/points_segmentation/feature_extractor/feature_extractor.cpp
        src/aloam/points_segmentation/image_labelers/abstract_image_labeler.cpp
        src/aloam/points_segmentation/image_labelers/diff_helpers/angle_diff.cpp
        src/aloam/points_segmentation/image_labelers/diff_helpers/line_dist_diff.cpp
        )

target_link_libraries(${PROJECT_NAME}
        ${Boost_LIBRARIES} -lgtsam -ltbb
        /usr/lib/x86_64-linux-gnu/libtbb.so
        )

add_executable(${PROJECT_NAME}_ascanRegistration src/aloam/scanRegistration.cpp)
add_executable(${PROJECT_NAME}_alaserOdometryCeres src/aloam/laserOdometryCeres.cpp)
add_executable(${PROJECT_NAME}_alaserOdometryGtsam src/aloam/laserOdometryGtsam.cpp)
add_executable(${PROJECT_NAME}_alaserMappingCeres src/aloam/laserMappingCeres.cpp)
add_executable(${PROJECT_NAME}_alaserMappingGtsam src/aloam/laserMappingGtsam.cpp)
add_executable(${PROJECT_NAME}_kittiHelper src/aloam/kittiHelper.cpp)

target_link_libraries(${PROJECT_NAME}_ascanRegistration ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}_alaserOdometryCeres ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES})
target_link_libraries(${PROJECT_NAME}_alaserOdometryGtsam ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES} gtsam)
target_link_libraries(${PROJECT_NAME}_alaserMappingCeres ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES})
target_link_libraries(${PROJECT_NAME}_alaserMappingGtsam ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES} gtsam)
target_link_libraries(${PROJECT_NAME}_kittiHelper ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS})
